Skip to content

fs: fix glob early return skipping sibling entries - #64895

Open
webdevelopersrinu wants to merge 1 commit into
nodejs:mainfrom
webdevelopersrinu:fix-glob-sibling-skip
Open

fs: fix glob early return skipping sibling entries#64895
webdevelopersrinu wants to merge 1 commit into
nodejs:mainfrom
webdevelopersrinu:fix-glob-sibling-skip

Conversation

@webdevelopersrinu

Copy link
Copy Markdown

The children loop in the glob traversal returned from the whole method when a
child path had already been seen through a different pattern context, silently
dropping the remaining sibling entries. Whether this triggered depended on
directory iteration order, which also made test-fs-glob.mjs flaky.

This removes the check — the cache.add call at the start of the traversal
already prevents reprocessing. Deno, which ports this implementation, fixed
the same bug.

The regression test pins the directory iteration order that triggers the bug,
so it fails deterministically without the fix (verified: without the fix,
a/b, a/x, a/z are missing from the results for pattern a/**/../*,
in both the sync and async implementations).

Supersedes #62901 — the author there agreed to hand over the work
(#62901 (comment)).

Fixes: #62897

@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Aug 1, 2026
@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 21, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 21, 2026
@trivikr

trivikr commented Aug 21, 2026

Copy link
Copy Markdown
Member

@webdevelopersrinu Can you please sign the first commit and force push?

It's required as per updated instructions

Your commit must contain the Signed-off-by line with your name and email address as an acknowledgement that you agree to the Developer Certificate of Origin

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

The children loop in the glob traversal returned from the whole method
when a child path had already been seen through a different pattern
context, silently dropping the remaining sibling entries. Whether this
triggered depended on directory iteration order, which also made
test-fs-glob.mjs flaky.

Remove the check: the cache.add call at the start of the traversal
already prevents reprocessing.

Fixes: nodejs#62897
Co-authored-by: semimikoh <ejffjeosms@gmail.com>
Signed-off-by: webdevelopersrinu <webdeveloper.srinu9@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fs.glob: return in cache-seen check aborts sibling processing, makes test-fs-glob.mjs flaky

4 participants